<?php
	if (!isset($component_name)) $component_name = '';
	if (!isset($component_desc)) $component_desc = '';
	if (!isset($owner))          $owner = '';
	if (!isset($active))         $active = '';
	if (!isset($component_id))   $component_id = '';
?>
<script language="JavaScript">
	var nameString = '<?php echo translate("Please enter a name"); ?>';
	var descString = '<?php echo translate("Please enter a description"); ?>';

	function checkForm(frm) {
		if (frm.component_name.value == '') {
			alert(nameString);
			frm.component_name.focus();
			return false;
		}
		if (frm.component_desc.value == '') {
			alert(descString);
			frm.component_desc.focus();
			return false;
		}
		return true;
	}
</script>
&nbsp;<b><?php echo $page_title; ?></b>
<hr size="1">
<?php if ($error) echo '<div class="error">'.$error.'</div>'; ?>
<form method="post" onSubmit="return checkForm(this)">
<table border="0">
    <tr>
        <td valign="top">
            <?php echo translate("Name"); ?>:
        </td>
        <td valign="top">
            <input type="text" name="component_name" value="<?php echo stripslashes(htmlspecialchars($component_name)); ?>">
        </td>
    </tr>
    <tr>
        <td valign="top">
            <?php echo translate("Description"); ?>:
        </td>
        <td valign="top">
            <textarea name="component_desc" cols="40" rows="10"><?php echo stripslashes(htmlspecialchars($component_desc)); ?></textarea>
        </td>
    </tr>
    <tr>
        <td valign="top">
            <?php echo translate("Owner"); ?>:
        </td>
        <td valign="top">
            <select name="owner"><option value="0"><?php echo translate("None"); ?></option><?php build_select('owner', $owner); ?></select>
        </td>
    </tr>
    <tr>
        <td align="right" valign="top">
            <?php echo translate("Sort Order"); ?>:
        </td>
        <td>
            <input type="text" size="3" maxlength="3" name="sort_order" value="<?php echo $sort_order; ?>">
        </td>
    </tr>
    <tr>
        <td valign="top">
            <?php echo translate("Active"); ?>:
        </td>
        <td valign="top">
            <input type="checkbox" name="active" value="1" <?php if ($active or !$component_id) echo 'checked'; ?>>
        </td>
    </tr>
    <tr>
        <td valign="top">
            &nbsp;
        </td>
        <td>
            <input type="submit" value="<?php echo translate("Submit"); ?>">
            <input type="hidden" name="component_id" value="<?php echo $component_id; ?>">
            <input type="hidden" name="project_id" value="<?php echo $project_id; ?>">
            <input type="hidden" name="use_js" value="<?php echo $_REQUEST['use_js']; ?>">
            <input type="hidden" name="op" value="save_component">
        </td>
    </tr>
</table>
</form>
